<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="keywords"  content="设置关键词..." />
    <meta name="description" content="设置描述..." />
    <meta name="author" content="DeathGhost" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <link rel="icon" href="images/icon/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link  rel="stylesheet" type="text/css" href="BootStrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="layui-v2.5.7/layui/css/layui.css"/>
    <script src="layui-v2.5.7/layui/layui.js"></script>
    <script src="BootStrap/js/jquery.js"></script>
    <script src="BootStrap/js/bootstrap.js"></script>
</head>
<body>
<div class="page-wrap">
    <section class="page-hd">
    <header>
        <h2 class="title">股东信息表</h2>
    </header>
    <hr>
</section>
    <div class="breadcrumb">
        <ul>
            <li><a >人员管理</a><i class="icon-angle-right"></i></li>
            <li><a href="gudonghefenxiaoshangtable.html">股东和分销商管理</a><i class="icon-angle-right"></i></li>
            <li>详情</li>
        </ul>
    </div>

</div>

<div class="page-wrap">

<form id="myform" class="form-inline">
    人员姓名:<br>
        <i class="icon-search"></i>
        <input type="text" class="form-control" placeholder="请输入股东姓名" id="guGongName" style="width:350px" name="guGongName">
        <br>
    人员角色:<br>
    <select class="form-control" name="usertype">
        <option value="">--所有类型--</option>
        <option value="4">股东</option>
        <option value="10">一级分销商</option>
        <option value="11">二级分销商</option>
    </select>
    <br>
    投资金额:<br>
    <input type="text" class="form-control" placeholder="请输入最小投资金额" style="width:280px"  name="minMoney">至
        <input type="text" class="form-control" placeholder="请输入最大投资金额" style="width:280px " name="maxMoney">
        <button type="button" class="btn btn-primary" name="Se">搜索</button>
        <button  class="btn btn-default" name="cl">清除</button><br>
    <br>
    <button type="button" class="btn btn-primary" name="zenjia" onclick="TianJian()">添加人员</button>
</form>
    </div>
<i class="layui-icon layui-icon-friends"></i>
<font size="4">总用户数:</font>
&nbsp;&nbsp;&nbsp;
<span id="user_count" style="font-size: 20px"></span>
<br/>
<div class="breadcrumb">
    <table class="table table-striped table-bordered table-hover" style="width: 100%;margin: 20px auto" >
        <thead>
        <tr>
            <th><input type="checkbox"/></th>
            <th>人员姓名</th>
            <th>人员电话</th>
            <th>人员角色</th>
            <th>投资金额（万元）</th>
            <th>收益分成(%)</th>
            <th>电子邮箱</th>
            <th>入伙时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="tbody">

        </tbody>
    </table>
        <ul class="pagination pull-right" id="page">

        </ul>
</div>
<!--增加模态框开始-->
<div class="modal fade" id="GuDongZengJia_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">股东分销商增加</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" style="width: 400px;margin: 0px auto" id="GuDong_add_Form" enctype="multipart/form-data" >
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员姓名：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="RenYuanXingMing">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员电话：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="RenYuanDianHua">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员角色：</label>
                        <div class="col-lg-8 ">
                            <select class="form-control"  required="required" name="RenYuanJueSe" >
                                <option >--所有类型--</option>
                                <option value="4">股东</option>
                                <option value="10">一级分销商</option>
                                <option value="11">二级分销商</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">投资金额（万元）：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="TouZiJinE">

                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">收益分成（%）：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="ShouYiFneCheng">

                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">电子邮箱：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="GuGongEmial">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">入伙时间：</label>
                        <div class="col-lg-8 ">
                            <input type="date" class="form-control"  required="required" name="RuHuoShijian">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员密码：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="RenYuanMiMa">
                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>
                <button type="button" class="btn btn-primary" id="Goods_Add_save_btn" onclick=BaoCunGuDong()>保存</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--增加模态框结结束-->
<!--编辑模态框开始-->
<div class="modal fade" id="GuDongBianJi_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">股东分销商修改</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" style="width: 400px;margin: 0px auto"  enctype="multipart/form-data" >
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员姓名：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="BianJiXingMing">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员电话：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="BianJiDianHua">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员角色：</label>
                        <div class="col-lg-8 ">
                            <select class="form-control"  required="required" name="BianJiJueSe" >
                                <option >--所有类型--</option>
                                <option value="4">股东</option>
                                <option value="10">一级分销商</option>
                                <option value="11">二级分销商</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">投资金额（万元）：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="BianJiJinE">

                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">收益分成（%）：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="BianJiFneCheng">

                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">电子邮箱：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="BianJiEmial">
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-lg-4 control-label">人员密码：</label>
                        <div class="col-lg-8 ">
                            <input type="text" class="form-control"  required="required" name="BianJiMiMa">
                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>
                <button type="button" class="btn btn-primary"  onclick=BianJiGuDong()>保存</button>
            </div>
            <input type="hidden" name="userIdBianJi">
            <input type="hidden" name="userSharingIdBianJi">
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--编辑模态框结束-->
<!--删除模态框开始-->
<div class="modal fade" id="delGuDong_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <h1 style="text-align: center">你确认要删除吗？</h1>
                <h2 style="text-align: center">删除该人员后需要重新添加</h2>
            </div>
            <input type="hidden" id="uid">
            <input type="hidden" id="sid">
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="delGuDong" onclick="delGudong()" >删除</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--删除模态框结束-->
<script>
    getAll(1);
    function getAll(pageNumber) {
        var guGongName=$(":input[name=guGongName]").val();
        var minMoney=$(":text[name=minMoney]").val();
        var maxMoney=$(":text[name=maxMoney]").val();
        var usertype=$("[name=usertype]").val();
    $.ajax({
        url:'/yonghu/getAll',
        type:'post',
        data:{"guGongName":guGongName,"minMoney":minMoney,"maxMoney":maxMoney,"pageNumber":pageNumber,"pageSize":null,"usertype":usertype},
        success:function (data) {
            if(data.result==true){
                var str="";
                for (var i = 0; i < data.gudong.length; i++) {
                    str+="<tr class='cen'>";
                    str+= "<td><input type='checkbox'/></td>";
                    str+="<td >"+data.gudong[i].username+"</td>";
                    str+="<td>"+data.gudong[i].userphone+"</td>";
                    str+="<td>"+(data.gudong[i].usertype==10?'一级分销商':(data.gudong[i].usertype==4?'股东':'二级分销商'))+"</td>";
                    str+="<td>"+data.sharing[i].usersharingamount+"</td>";
                    str+="<td>"+data.sharing[i].usersharing+"</td>";
                    str+="<td>"+data.gudong[i].useremail+"</td>";
                    str+="<td>"+data.gudong[i].userregistrationtime+"</td>";
                    str+="<td>";
                    str+="<input type='hidden' name='userId' value='"+data.gudong[i].userid+"'>";
                    str+="<input type='hidden' name='usersharingId' value='"+data.sharing[i].usersharingid+"'>";
                    str+="<a title='编辑' class='mr-5' onclick='BianJi("+data.gudong[i].userid+","+data.sharing[i].usersharingid+")'>编辑</a>";
                    str+= " <a title='详情' class='mr-5' onclick='tiaohzung("+data.gudong[i].userid+","+data.sharing[i].usersharingid+")')'>详情</a>";
                    str+= " <a  name='del' onclick='del("+data.gudong[i].userid+","+data.sharing[i].usersharingid+")'> 删除</a>";
                    str+="</td></tr>";
                }
                $("#tbody").html(str);
                var page="";
                page+='<li class="'+(data.page.pageNum==1?'disabled':'')+'"><a onclick="getAll('+data.page.prePage+')" >上一页</a></li>';
                for (var i =1;i<=data.page.pages ; i++) {
                    page+=' <li class="'+(data.page.pageNum==i?'active':'')+'"><a onclick="getAll('+i+')">'+i+'<span class="sr-only"></span></a></li>';
                }
                page+=' <li ><a onclick="getAll('+data.page.nextPage+')" >下一页</a></li>';
                $("#page").html(page);
                $("#user_count").html(data.page.total);
            }

        }
    });

    }

    // 根据股东姓名查询
    se();
    function se() {
        $(":button[name=Se]").click(function (){
            getAll(1);
        });

    }
    function cl() {
        $(":button[name=cl]").click(function (){
            $("#myform")[0].reset();
            getAll(1);
        });
    }

    //删除弹出模态框

    function del(userId,sharingId){
         $("#uid").val(userId);
         $("#sid").val(sharingId);
            $("#delGuDong_modal").modal("show");


    }
    //确认删除删除模态框

    function delGudong() {
      var userId=$("#uid").val();
       var usersharingId=$("#sid").val();

                $.ajax({
                   type:'post',
                   url:'/yonghu/delGuGong',
                   data:{"userId":userId,"usersharingId":usersharingId},
                    success:function (data){
                           $("#delGuDong_modal").modal("hide");
                            getAll(1);

            }
                });

    }
    //增加模态框弹出
    function TianJian(){
        $("#GuDong_add_Form")[0].reset();
        $("#GuDongZengJia_modal").modal("show");
    }
    //股东信息保存
    function  BaoCunGuDong(){

        $.ajax({
            url:'/yonghu/TianJiaGuGong',
            type:'post',
            data:{"RenYuanXingMing":$("[name=RenYuanXingMing]").val(),"RenYuanDianHua":$("[name=RenYuanDianHua]").val(),"RenYuanJueSe":$("[name=RenYuanJueSe]").val(),"TouZiJinE":$("[name=TouZiJinE]").val(),"ShouYiFneCheng":$("[name=ShouYiFneCheng]").val(),"GuGongEmial":$("[name=GuGongEmial]").val(),"RuHuoShijian":$("[name=RuHuoShijian]").val(),"RenYuanMiMa":$("[name=RenYuanMiMa]").val()},
            success:function (data){
                $("#GuDongZengJia_modal").modal("hide");
                $("#myform")[0].reset();
                getAll(1);
            }
        });
    }
    /*
       编辑模态框弹出
    * */
    function BianJi(userId,usersharingId){
        $.ajax({
           url:'/yonghu/BianJIGuGong',
           type:'post',
           data:{"userId":userId,"usersharingId":usersharingId},
           success:function (data){
               $("[name=BianJiXingMing]").val(data.sesUser.username);
               $("[name=BianJiDianHua]").val(data.sesUser.userphone);
               $("[name=BianJiJueSe]").val(data.sesUser.usertype);
               $("[name=BianJiJinE]").val(data.sesUserSharing.usersharingamount);
               $("[name=BianJiFneCheng]").val(data.sesUserSharing.usersharing);
               $("[name=BianJiEmial]").val(data.sesUser.useremail);
               $("[name=BianJiMiMa]").val(data.sesUser.userpassword);
               $("[name=userIdBianJi]").val(data.sesUser.userid);
               $("[name=userSharingIdBianJi]").val(data.sesUserSharing.usersharingid);

               $("#GuDongBianJi_modal").modal("show");

           }
        });
    }
    function  BianJiGuDong(){
        alert( $("[name=userSharingIdBianJi]").val());
        $.ajax({
           url:'/yonghu/BianJIGuGongBaoCun',
           type:'post',
           data:{"BianJiXingMing": $("[name=BianJiXingMing]").val(),"BianJiDianHua": $("[name=BianJiDianHua]").val(),"BianJiJueSe": $("[name=BianJiJueSe]").val(),"BianJiJinE": $("[name=BianJiJinE]").val(),"BianJiFneCheng":$("[name=BianJiFneCheng]").val(),"BianJiEmial":$("[name=BianJiEmial]").val(),"BianJiMiMa": $("[name=BianJiMiMa]").val(),"userId": $("[name=userIdBianJi]").val(),"userSharingId":$("[name=userSharingIdBianJi]").val()},
            success:function (data){
                $("#GuDongBianJi_modal").modal("hide");
                getAll(1);
            }
        });
    }
    //
    function tiaohzung(uid,shid){
        window.localStorage.setItem("userid",uid);
        window.localStorage.setItem("sid",shid);
        location.href="guDongXiangQing.html";
    }
</script>
</body>
</html>
